from Products.ShoeBox.config import PROJECTNAME
from Products.Archetypes.public import listTypes
from Products.Archetypes.Extensions.utils import installTypes, install_subskin
from StringIO import StringIO
from Products.ShoeBox.config import GLOBALS
from Products.CMFCore.utils import getToolByName

def install(self):
	out = StringIO()

	##
	## Install ShoeBox
	##
	installTypes(self, out,
		listTypes(PROJECTNAME),
		PROJECTNAME)
	
	##
	## Install skin
	##
	install_subskin(self, out, GLOBALS)
	
	##
	## Install ShoeBoxTool
	##
#	if not hasattr(self, 'ShoeBoxTool'):
#		addTool = self.manage_addProduct['ShoeBox'].manage_addTool
#		## Add the tool by its meta_type
#		addTool('Plone Shoe Box Tool')

	##
	## Print install info
	##
	updateNavtreeProperties(self)
	
	print >> out, "Successfully installed %s." % PROJECTNAME
	return out.getvalue()
	
def updateNavtreeProperties(self):
	"""
	Make sure Entries are never listed in nav tree
	"""
	ptool = getToolByName(self, 'portal_properties')
	unlisted = ptool.navtree_properties.getProperty('metaTypesNotToList')
	new_unlisted = []

	for item in unlisted:
		new_unlisted.append(item)

	new_unlisted.append('ShoeBoxEntry')
	ptool.navtree_properties._updateProperty('metaTypesNotToList', new_unlisted)